SRCS += $(wildcard *.c)
SRCS += $(wildcard *.cpp)
OBJS = $(foreach src, $(SRCS), $(basename $(src)).o )

TARGETS = pty

CXX = g++

CFLAGS += -pipe -Wall -g
CFLAGS += -I ../common
CDFLAGS += -L ../common -l apue_error
CDFLAGS += -lm

######################################
.PHONY: all clean

all : $(TARGETS) 

$(TARGETS) : $(OBJS) ../common/libapue_error.a
	$(CXX) -o $@ $^ $(CDFLAGS)

../common/libapue_error.a: $(wildcard ../common/*.cpp) $(wildcard ../common/*.c) $(wildcard ../common/*.h)
	make -C ../common

clean:
	-rm $(TARGETS) $(OBJS)

#######################################
.SUFFIXES : .cpp .c

.cpp.o :
	$(CXX) $(CFLAGS) -c -o $@ $<

.c.o :
	$(CXX) $(CFLAGS) -c -o $@ $<
